load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "gomock")

# For this test, the mock is included as part of the library
go_library(
    name = "client",
    srcs = [
        "client.go",
        "client_mock.go",
    ],
    importpath = "github.com/bazelbuild/rules_go/gomock/client",
    visibility = ["//visibility:public"],
    deps = [
        "@com_github_golang_mock//gomock",
        "@org_golang_google_genproto_googleapis_bytestream//:bytestream",
        "@org_golang_google_grpc//:grpc",
    ],
)

# Pass importpath instead of library to the generation step
# Passing library instead of importpath here will cause a circular dependency
gomock(
    name = "mocks",
    out = "client_mock.go",
    package = "client",
    source = "client.go",
    source_importpath = "github.com/bazelbuild/rules_go/gomock/client",
    visibility = ["//visibility:public"],
)

# Don't include client_mock.go as a source file, instead use it from the library
go_test(
    name = "client_test",
    srcs = [
        "client_test.go",
    ],
    embed = [":client"],
)
